package com.meng.mmlive.ui.adapter;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.meng.baselibrary.adapter.BaseRecycleViewAdapter;
import com.meng.mmlive.R;
import com.meng.mmlive.entity.Adverts;
import com.meng.mmlive.entity.HomeMenu;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/5/14.
 */

public class HomeRecyclerViewAdapter extends BaseRecycleViewAdapter<HomeMenu> {
    public HomeRecyclerViewAdapter(Context context) {
        super(context);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateItemViewHolder(ViewGroup parent, int viewType) {

        return new ItemViewHolder(getInflater().inflate(R.layout.item_home_anchor_group, null));
    }

    @Override
    protected void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) {
        ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
        HomeMenu data = getItem(position);
        itemViewHolder.titleTv.setText(data.getMenuName());
        itemViewHolder.anchorRecyclerViewAdapter.setDatas(data.getDataList());
    }

    public void setAdvertses(List<Adverts> advertses) {

    }

    class ItemViewHolder extends BaseRecycleViewAdapter.ItemViewHolder {
        @Bind(R.id.titleTv)
        TextView titleTv;
        @Bind(R.id.recyclerView)
        RecyclerView recyclerView;
        @Bind(R.id.show_all)
        ImageView showAll;
        HomeAnchorRecyclerViewAdapter anchorRecyclerViewAdapter;
        public ItemViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            anchorRecyclerViewAdapter = new HomeAnchorRecyclerViewAdapter(itemView.getContext());
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(itemView.getContext());
            linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
            recyclerView.setLayoutManager(linearLayoutManager);
            recyclerView.setAdapter(anchorRecyclerViewAdapter);
        }
    }
}
